PHP Functional Programming, helper function, annonymous function, closure
Posted on January 31, 2017, 5:03 pm, by admin, under
php.
<?php
$url = function($folder) use ($hostname) {
return $hostname . DIRECTORY_SEPARATOR . $folder;
};
$hostname = "https://" . $_SERVER['SERVER_NAME'];
$myurl = $url('pictures');
echo $myurl;
// output
// https://www.aghayev.com/pictures |
<?php
$url = function($folder) use ($hostname) {
return $hostname . DIRECTORY_SEPARATOR . $folder;
};
$hostname = "https://" . $_SERVER['SERVER_NAME'];
$myurl = $url('pictures');
echo $myurl;
// output
// https://www.aghayev.com/pictures